(function() {
	'use strict';

	CCR.Models.Player = Backbone.Model.extend({
		// 播放器
		status :null,// 播放状态
		currentMediaHandle : 0, // 当前歌曲句柄
		// 播放
		doPlay : function(s, songinfo) {

			if (!songinfo.songurl) {
				return;
			}

			var self = s;

			// 播放歌曲
			var song_url = songinfo.songurl.url[0];
			if(PlaySongFlag){
				CCR.Media.play(song_url.file_link, {
					timeupdate:function(t,status){
						log("player callback: timeupdate time="+changeMillisecondTime(t+1500));
						$("#currentSongStatus").html((t));
						CCR.Lrc.lrcTorun(t/1000);
					},
					play:function(){
						log("play callback: play");
						$("#playBtn").html("暂停");
					},
					pause:function(){
						log("play callback: pause");
						$("#playBtn").html("播放");
					},
					stop:function(){
						log("play callback: stop");
						CCR.Songs.playNext(CCR.Songs);
					},
				});
			}
			//加载歌词信息
			this.getLrc(songinfo, s);

		},

		// 或缺歌词信息
		getLrc : function(songinfo, s) {

			var self = s;

			var url = songinfo.songinfo.lrclink;
			 $.ajax({
				 url: url,
				 success: function(data) {
					//$(".lyrics_content").html(data);
					/*<ul>
	    			<li class="normalLyric">What's your point,wasting time</li>
	    			<li class="currentLyric">But how many times you stand up</li>
	    			<li class="currentLyric">for yourself</li>
	    			<li class="normalLyric">your life,belongs to nobody else</li>
	    			</ul>
	    			*/
					 
					 CCR.Lrc.lrcLoad(CCR.Lrc.lrcRead(data));
				 },
			 });
//			
//			$.ajax({ type : "get", async : true, url : url, cache : false,
//				success : function(data) {
//					if (data) {
//						self.songlrc = data.split('\n');
//					}
//
//				}, error : function(err) {
//					// alert(err);
//				} });
		},

		// 暂停
		doPause : function() {
			CCR.Media.pasue();
		},

		// 停止
		doStop : function() {
			CCR.Media.stop();
		},

		// 拖拽播放
		doSeek : function() {

		},

		initialize : function(options) {
			CCR.Comm.log("Initializing player: "
					+ JSON.stringify(this.toJSON()));
		}, 
		
	});

})();


